import automaton.DFA;
import helpers.AutomataGeneration;
import helpers.RunWithTimeOut;


public class Console_Test {

	public static void main(String[] args) {
		// run from file
		if (args.length == 3)
		{
			long timeout = 0;
			
			try {
				timeout = Long.parseLong(args[2]);
				
				Thread thread = new Thread(new RunWithTimeOut(args[0], args[1]));
				thread.start();
				if (timeout > 0)
					thread.join(timeout);
			} catch (Exception e) {
				System.out.println("Wrong input !!!");
			}	
		}
		// run and generating automata
		else if (args.length == 4)
		{
			try {
				int noAutomata = Integer.parseInt(args[0]);
				int noState = Integer.parseInt(args[1]);
				int noLabel = Integer.parseInt(args[2]);
				long timeout = Long.parseLong(args[3]) * 100;
				
				for (int i=0; i< noAutomata; i++)
				{
					DFA automata = AutomataGeneration.automaticGeneration(noState, noLabel);
					Thread thread = new Thread(new RunWithTimeOut(automata));
					thread.start();
					if (timeout>0)
						thread.join(timeout);
				}
			} catch (Exception e) {
				System.out.println(e.getMessage());
			}
		}
		else
		{
			System.out.println("Wrong command line !!!");
		}
	}

}
